home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tclX-6.4 / help / intro / syntax < prev    next >
Encoding:
Text File  |  1992-12-17  |  4.4 KB  |  81 lines

  1.      BASIC COMMAND SYNTAX
  2.           The Tcl language has syntactic similarities to both the Unix
  3.           shells and Lisp.  However, the interpretation of commands is
  4.           different in Tcl than in either of those other two  systems.
  5.           A  Tcl  command  string  consists  of  one  or more commands
  6.           separated  by  newline  characters  or  semi-colons.    Each
  7.           command  consists  of  a  collection  of fields separated by
  8.           white space (spaces or tabs).  The first field must  be  the
  9.           name  of  a  command, and the additional fields, if any, are
  10.           arguments that will be passed to that command.  For example,
  11.           the command
  12.  
  13.                set a 22
  14.  
  15.           has three fields:  the first, set, is  the  name  of  a  Tcl
  16.           command,  and  the  last  two,  a  and 22, will be passed as
  17.           arguments to the set command.  The command  name  may  refer
  18.           either  to  a  built-in Tcl command, an application-specific
  19.           command   bound    in    with    the    library    procedure
  20.           Tcl_CreateCommand,  or  a command procedure defined with the
  21.           proc built-in command.  Arguments are  passed  literally  as
  22.           text  strings.   Individual  commands  may  interpret  those
  23.           strings in any fashion they  wish.   The  set  command,  for
  24.           example,  will  treat  its  first  argument as the name of a
  25.           variable and its second argument as a string value to assign
  26.           to  that  variable.   For  other  commands  arguments may be
  27.           interpreted as integers, lists, file names, or Tcl commands.
  28.  
  29.           Command names should normally be typed completely  (e.g.  no
  30.           abbreviations).   However,  if  the  Tcl  interpreter cannot
  31.           locate a command it invokes a special command named  unknown
  32.           which  attempts to find or create the command.  For example,
  33.           at  many  sites  unknown   will   search   through   library
  34.           directories  for  the desired command and create it as a Tcl
  35.           procedure  if  it  is  found.   The  unknown  command  often
  36.           provides  automatic  completion of abbreviated commands, but
  37.           usually only for commands  that  were  typed  interactively.
  38.           It's  probably  a  bad  idea to use abbreviations in command
  39.           scripts and other forms that  will  be  re-used  over  time:
  40.           changes to the command set may cause abbreviations to become
  41.           ambiguous, resulting in scripts that no longer work.
  42.  
  43.  
  44.      COMMAND SUMMARY
  45.           [1]  A command is just a string.
  46.  
  47.           [2]  Within a string commands are separated by  newlines  or
  48.                semi-colons (unless the newline or semi-colon is within
  49.                braces or brackets or is backslashed).
  50.  
  51.           [3]  A command consists of fields.  The first field  is  the
  52.                name of the command.  The other fields are strings that
  53.                are passed to that command as arguments.
  54.  
  55.           [4]  Fields are normally separated by white space.
  56.  
  57.           [5]  Double-quotes allow  white  space  and  semi-colons  to
  58.                appear within a single argument.  Command substitution,
  59.                variable substitution, and backslash substitution still
  60.                occur inside quotes.
  61.  
  62.           [6]  Braces defer interpretation of special characters.   If
  63.                a  field  begins with a left brace, then it consists of
  64.                everything between the  left  brace  and  the  matching
  65.                right  brace. The braces themselves are not included in
  66.                the argument.  No further processing  is  done  on  the
  67.                information  between  the braces except that backslash-
  68.                newline sequences are eliminated.
  69.  
  70.           [7]  If a field doesn't begin with a brace  then  backslash,
  71.                variable,  and  command  substitution  are  done on the
  72.                field.  Only a single level of processing is done:  the
  73.                results  of  one substitution are not scanned again for
  74.                further substitutions or any other  special  treatment.
  75.                Substitution  can  occur  on  any  field  of a command,
  76.                including the command name as well as the arguments.
  77.  
  78.           [8]  If the first non-blank character of a command is  a  #,
  79.                everything  from  the  # up through the next newline is
  80.                treated as a comment and ignored.
  81.